﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for ChanelData
/// </summary>
public class ChanelData
{
	public ChanelData()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool add(ChannelesEntities item)
    {
        bool flat = false;
        string[] paramaters = { "@name", "@parent", "@lock" };
        string[] values = {item._name,item._parent.ToString(),item._channelLock };
        if (Database.getExecProcedure("sp_InsertChannel", paramaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool edit(ChannelesEntities item)
    {
        bool flat = false;
        string[] paramaters = {"@id", "@name", "@parent", "@lock" };
        string[] values = {item._id.ToString(), item._name, item._parent.ToString(), item._channelLock };
        if (Database.getExecProcedure("sp_UpdateChannel", paramaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public bool UpChanel(int id)
    {
        bool flat = false;
        string[] paramaters = { "@id" };
        string[] values = { id.ToString() };
        if (Database.getExecProcedure("sp_UpChannel", paramaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public bool DrownChanel(int id)
    {
        bool flat = false;
        string[] paramaters = { "@id" };
        string[] values = { id.ToString() };
        if (Database.getExecProcedure("sp_drownChannel", paramaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public bool delete(int id)
    {
        bool flat = false;
        string[] paramaters = { "@id"};
        string[] values = { id.ToString() };
        if (Database.getExecProcedure("sp_DeleteChannel", paramaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }
    public System.Data.SqlClient.SqlDataReader getChanel(int id)
    {
        return Database.getReader("exec sp_GetChannel '"+id.ToString()+"'");     
    }

}
